﻿using System.Collections.Generic;
using System.Linq;
using Silent.WCF.Interfaces;

namespace Silent.WCF.Base
{
    public abstract class ClientServiceManagerBase : IService
    {
        private readonly List<object> m_clientServices;

        protected ClientServiceManagerBase()
        {
            m_clientServices = new List<object>();
        }

        public abstract void Initialize();

        public void AddService<T>(IClientService<T> service) where T : class, IService
        {
            m_clientServices.Add(service);
        }
        public IClientService<T> GetService<T>() where T : class, IService
        {
            var service = m_clientServices.FirstOrDefault(x => x is IClientService<T>);
            return service as IClientService<T>;
        }
    }
}